package MainPackage;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.ArrayList;


public class dsadffg {

	static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	//static BufferedReader reader;		
	
	public static void main(String[] args) throws Exception {
		//reader = new BufferedReader(new FileReader("salesman_input.txt"));
		new dsadffg().run();
	}

	void runBellmanFordRun(int origin, int destination, ArrayList<int[]> al, int towns){
		long[] d = new long[towns];
		bellmanFord(origin, al, towns, d);
		
		if(d[destination] == Integer.MAX_VALUE)
		{
			System.out.println("IMPOSSIBLE");
			return;
		}
		
		ArrayList<Integer> endlessProfitCitys = new ArrayList<Integer>();
		for( int[] ia: al )
		{
			if(d[ ia[0] ] != Integer.MAX_VALUE && (d[ ia[0] ] + ia[2]  <  d[ ia[1] ] ) )
			{
				endlessProfitCitys.add(ia[1]);
			}
		}
		if (!endlessProfitCitys.isEmpty())
		{
			// Neuen Superstartknotnen hinzufügen
			for (Integer city : endlessProfitCitys) {
				al.add(new int[] { towns, city, 0 });
			}
			
			long[] d2 = new long[towns + 1];
			this.bellmanFord(towns, al, towns + 1, d2);
			if (d2[destination] != Integer.MAX_VALUE){
				System.out.println("ENDLESS PROFIT");
				return;
			}
		}
		
		
		System.out.println("BEST PROFIT: "+ d[destination] * -1);
	}
	
	void bellmanFord(int origin, ArrayList<int[]> al, int towns, long[] d)
	{
		int[] pre = new int[towns];
		
		for(int i=0; i< towns; i++)
		{
			d[i] = Integer.MAX_VALUE;
			pre[i] = -1;
		}
		
		d[origin] =  0;
		for(int i = 1; i < towns; i++)
			for( int[] ia: al ){
				if(  d[ ia[0] ] != Integer.MAX_VALUE    &&     (d[ ia[0] ] +  ia[2]  <  d[ ia[1] ] )   )
				{  
					d[ ia[1] ] = d[ ia[0] ] + ia[2] ;
					pre[ ia[1] ]  = ia[0];
				}
			}
	}
	
	void run() throws Exception{
		String line = reader.readLine();
		if(line.equals("END")) {reader.close(); return;}
		String[] split = line.split(" ");
		int towns = Integer.parseInt(split[0]);
		int roads = Integer.parseInt(split[1]);
		int origin = Integer.parseInt(split[2]);
		int destination = Integer.parseInt(split[3]);
			
		line = reader.readLine();
		String[] splitamounts = line.split(",");
		int[] amounts = new int[towns];
		for(int i=0; i< towns;i++)
			amounts[i] = Integer.parseInt(splitamounts[i]);
		
		ArrayList<int[]> al = new ArrayList<int[]>();
		for(int i = 0; i < roads; i++)
		{
			line = reader.readLine();
			split = line.split(" ");
			int[] intsplit = new int[split.length]; 
			for(int j = 0; j < split.length; j++)
			{
				// Amounts zu den Kanten hinzuaddieren, da man nun den originalen Bellman Ford benutzen kann.
				// In 2 steht der Amount.
				if (j == 2)
				{
					intsplit[j] = (amounts[intsplit[1]] - Integer.parseInt(split[j])) * -1;
					break;
				}
				intsplit[j] = Integer.parseInt(split[j]);
			}
			al.add(intsplit);
		}
		// Neuen Startknotnen hinzufügen mit Kante zum ursprünglichen Startknoten mit amount der ursprünglichen Startnotens
		al.add(new int[] { towns, origin, amounts[0] * -1});
		
		new dsadffg().runBellmanFordRun(towns, destination, al, towns + 1);
		new dsadffg().run();
	}
	
}